// pages/order/order.js
import {a} from '../../util/synspro.js'
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

    synbasic:app.globalData.synbasic,
    synwork:app.globalData.synbasic,
    basic1:0,
    work1:0,
    contacts1:0,
    car1:0,
    imagepl1:0

  },

  /****
   * 保存数据
   */
  savedata:function(){


    
    if(true)
    //清空缓存
    {
      wx.removeStorageSync('custname'),               //姓名
      wx.removeStorageSync('idcard'),           //身份证号
      wx.removeStorageSync('phone'),            //手机号
      wx.removeStorageSync('sex'),//性别
      wx.removeStorageSync('marriage'),//婚姻状态
      wx.removeStorageSync('gender'),//学历
      wx.removeStorageSync('address'),//现住地址
      wx.removeStorageSync('address2'),                       //现住详细地址
      wx.removeStorageSync('hometype'),  //住房类型
      wx.removeStorageSync('homesize'),            //家庭人口
      wx.removeStorageSync('applymoney'),              //申请金额
      wx.removeStorageSync('homephone'),//家庭手机

      wx.removeStorageSync('companyname'),
      wx.removeStorageSync('companyaddress'),
      wx.removeStorageSync('companyaddress1'),
      wx.removeStorageSync('companyphone'),
      wx.removeStorageSync('companydept'),
      wx.removeStorageSync('companylevel'),
      wx.removeStorageSync('companyannualincomeaftertax'),
      wx.removeStorageSync('companyworkyear'),

      //linkmanfirstname
      wx.removeStorageSync('linkmanfirstname'),
      wx.removeStorageSync('linkmanfirstnhone'),
      wx.removeStorageSync('linkmanrelation'),
      wx.removeStorageSync('linkmanfriendname'),
      wx.removeStorageSync('linkmanfriendphone'),
      wx.removeStorageSync('linkmanguarantorname'),
      wx.removeStorageSync('linkmanguarantorphone'),
      wx.removeStorageSync('nameandlinkmanguarantorrelation'),

      //车辆
      wx.removeStorageSync('carzz'),
      wx.removeStorageSync('carhz'),
      wx.removeStorageSync('caresc'),
      wx.removeStorageSync('carcdd'),
      wx.removeStorageSync('carpp'),
      wx.removeStorageSync('carcx'),
      wx.removeStorageSync('carpz'),
      wx.removeStorageSync('carspd'),
      wx.removeStorageSync('carzdj'),
      wx.removeStorageSync('carcolor'),
      wx.removeStorageSync('carpl'),

      wx.removeStorageSync('imgcard');
      wx.removeStorageSync('imgjsz');
      wx.removeStorageSync('imgyhk');
      wx.removeStorageSync('imgzxsqs');
      wx.removeStorageSync('imgzxsqsqzz');
      wx.removeStorageSync('imgscssfz');
      wx.removeStorageSync('imgscsfz');
      wx.removeStorageSync('imgtbd');
      wx.removeStorageSync('imgtbdqzz');
      wx.removeStorageSync('imgtbsm');
      wx.removeStorageSync('imggkxy');
      wx.removeStorageSync('imggcht');
      wx.removeStorageSync('imgtjh');
      wx.removeStorageSync('imgdbh');
      wx.removeStorageSync('imgsfkpz');
      wx.removeStorageSync('imgkhgzs');
      wx.removeStorageSync('imgdkwtsqs');
      wx.removeStorageSync('imgzhcxsqs');
      wx.removeStorageSync('imgzlht');
      wx.removeStorageSync('imgdyht');
      wx.removeStorageSync('imgygqrs');
      wx.removeStorageSync('imgwtfks');
      wx.removeStorageSync('imgqt');
      
      wx.removeStorageSync('img2pocard');
      wx.removeStorageSync('img2zxsqs');
      wx.removeStorageSync('img2zxsqsqzz');
      wx.removeStorageSync('img2zxsqssfzscz');
      wx.removeStorageSync('img2sczsfz');
      wx.removeStorageSync('img2bkcxdbs');
      wx.removeStorageSync('img2gthkcns');
      wx.removeStorageSync('img2jhzlhz');
      wx.removeStorageSync('img2hkb');
      wx.removeStorageSync('img2sqrls');
      wx.removeStorageSync('img2dbrls');
      wx.removeStorageSync('img2fczm');
      wx.removeStorageSync('img2sbk');
      wx.removeStorageSync('img2jfzp');
      wx.removeStorageSync('img2qt');
      }


    var that = this;
/*
    if(that.data.basic1 == 0){


      wx.showToast({
        title: '基本信息为空！',
        icon: "none",
        duration: 1000
      })

      return;

    }

    
    if(that.data.work1 == 0){

      wx.showToast({
        title: '工作信息为空！',
        icon: "none",
        duration: 1000
      })

      return;
    }

    if(that.data.contacts1 == 0){


      wx.showToast({
        title: '联系人为空！',
        icon: "none",
        duration: 1000
      })

      return;

    }

    if(that.data.car1 == 0){


      wx.showToast({
        title: '车辆信息为空！',
        icon: "none",
        duration: 1000
      })

      return;

    }

    if(that.data.imagepl1 == 0){


      wx.showToast({
        title: '图片采集为空！',
        icon: "none",
        duration: 1000
      })
      return;
    }
    */


    wx.request({
      url: 'https://wx.wc5818.com/wxapp/api/addWC_FK_CustInfo',
      method: "POST",
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
      data: {

        user_login_name:app.globalData.gluserName,
        orderid:wx.getStorageSync('ordernum'), //获取订单
        status:'待预审',//订单状态 
        custname: wx.getStorageSync('custname'),               //姓名
        idcard: wx.getStorageSync('idcard'),           //身份证号
        phone: wx.getStorageSync('phone'),            //手机号
        sex: wx.getStorageSync('sex'),//性别
        marriage: wx.getStorageSync('marriage'),//婚姻状态
        gender: wx.getStorageSync('gender'),//学历
        address: wx.getStorageSync('address'),//现住地址
        address2: wx.getStorageSync('address2'),                       //现住详细地址
        hometype: wx.getStorageSync('hometype'),  //住房类型
        homesize: wx.getStorageSync('homesize'),            //家庭人口
        applymoney: wx.getStorageSync('applymoney'),              //申请金额
        homephone: wx.getStorageSync('homephone'),//家庭手机

        companyname: wx.getStorageSync('companyname'),
        companyaddress: wx.getStorageSync('companyaddress'),
        companyaddress1: wx.getStorageSync('companyaddress1'),
        companyphone: wx.getStorageSync('companyphone'),
        companydept: wx.getStorageSync('companydept'),
        companylevel: wx.getStorageSync('companylevel'),
        companyannualincomeaftertax: wx.getStorageSync('companyannualincomeaftertax'),
        companyworkyear: wx.getStorageSync('companyworkyear'),

        //linkmanfirstname
        linkmanfirstname: wx.getStorageSync('linkmanfirstname'),
        linkmanfirstnhone: wx.getStorageSync('linkmanfirstnhone'),
        linkmanrelation: wx.getStorageSync('linkmanrelation'),
        linkmanfriendname: wx.getStorageSync('linkmanfriendname'),
        linkmanfriendphone: wx.getStorageSync('linkmanfriendphone'),
        linkmanguarantorname: wx.getStorageSync('linkmanguarantorname'),
        linkmanguarantorphone: wx.getStorageSync('linkmanguarantorphone'),
        nameandlinkmanguarantorrelation: wx.getStorageSync('nameandlinkmanguarantorrelation'),

        //车辆
        carzz: wx.getStorageSync('carzz'),
        carhz: wx.getStorageSync('carhz'),
        caresc: wx.getStorageSync('caresc'),
        carcdd: wx.getStorageSync('carcdd'),
        carpp: wx.getStorageSync('carpp'),
        carcx: wx.getStorageSync('carcx'),
        carpz: wx.getStorageSync('carpz'),
        carspd: wx.getStorageSync('carspd'),
        carzdj:wx.getStorageSync('carzdj'),
        carcolor:wx.getStorageSync('carcolor'),
        carpl:wx.getStorageSync('carpl'),

        //图片保存
        imgmodeltype:'1',
        imgcard: wx.getStorageSync('imgcard'),
        imgjsz: wx.getStorageSync('imgjsz'),
        imgyhk: wx.getStorageSync('imgyhk'),
        imgzxsqs: wx.getStorageSync('imgzxsqs'),
        imgzxsqsqzz: wx.getStorageSync('imgzxsqsqzz'),
        imgscssfz: wx.getStorageSync('imgscssfz'),
        imgscsfz: wx.getStorageSync('imgscsfz'),
        imgtbd: wx.getStorageSync('imgtbd'),
        imgtbdqzz: wx.getStorageSync('imgtbdqzz'),
        imgtbsm: wx.getStorageSync('imgtbsm'),
        imggkxy: wx.getStorageSync('imggkxy'),
        imggcht: wx.getStorageSync('imggcht'),
        imgtjh:wx.getStorageSync('imgtjh'),
        imgdbh:wx.getStorageSync('imgdbh'),
        imgsfkpz:wx.getStorageSync('imgsfkpz'),
        imgkhgzs:wx.getStorageSync('imgkhgzs'),
        imgdkwtsqs:wx.getStorageSync('imgdkwtsqs'),
        imgzhcxsqs:wx.getStorageSync('imgzhcxsqs'),
        imgzlht:wx.getStorageSync('imgzlht'),
        imgdyht:wx.getStorageSync('imgdyht'),
        imgygqrs:wx.getStorageSync('imgygqrs'),
        imgwtfks:wx.getStorageSync('imgwtfks'),
        imgqt:wx.getStorageSync('imgqt'),

        img2pocard:wx.getStorageSync('img2pocard'),
        img2zxsqs:wx.getStorageSync('img2zxsqs'),
        img2zxsqsqzz:wx.getStorageSync('img2zxsqsqzz'),
        img2zxsqssfzscz:wx.getStorageSync('img2zxsqssfzscz'),
        img2sczsfz:wx.getStorageSync('img2sczsfz'),

        img2bkcxdbs:wx.getStorageSync('img2bkcxdbs'),
        img2gthkcns:wx.getStorageSync('img2gthkcns'),
        img2jhzlhz:wx.getStorageSync('img2jhzlhz'),
        img2hkb:wx.getStorageSync('img2hkb'),
        img2sqrls:wx.getStorageSync('img2sqrls'),

        img2dbrls:wx.getStorageSync('img2dbrls'),
        img2fczm:wx.getStorageSync('img2fczm'),
        img2sbk:wx.getStorageSync('img2sbk'),
        img2jfzp:wx.getStorageSync('img2jfzp'),
        img2qt:wx.getStorageSync('img2qt'),



      },

      // 成功执行
      success(res) {
        

        console.log(res.data);
        console.log(res);

        if(res.data==1)
         {




          
      //认领后改变状态
      wx.request({
        url: app.globalData.wancheURL + 'upWCCOMOrderStatusForNum',
        method:'POST',
        header:{
          "Content-Type": "application/x-www-form-urlencoded",

        },
        data:{

          ordernum:wx.getStorageSync('ordernum'),
          status:'待预审' 
        },
        success(res) {
          wx.showToast({
            title: '保存成功！',
            icon: "success",
            duration: 1000
          }),
          wx.navigateTo({
            url: 'pages/all/personage/personage',
          })
        }
      })
      }else{
        wx.showToast({
          title: '保存失败！',
          icon: "error",
          duration: 1000
        })
      }
      }
    })
  },
  fengkong:function(){
    wx.navigateTo({
      url: '../inquire/inquire' ,
    })
  },

  // 基本信息跳转
  basic:function () {

    this.data.basic1 = 1;

    wx.navigateTo({
      url: '../basic/basic' ,
    })
  },
  // 工作信息跳转
  work:function () {

    this.data.work1 = 1;
    wx.navigateTo({
      url: '../work/work' ,
    })
  },
  // 联系人信息跳转
  contacts:function () {
    this.data.contacts1 = 1;
    wx.navigateTo({
      url: '../contacts/contacts' ,
    })
  },
  // 车辆信息跳转
  vehicle:function () {
    this.data.car1=1;
    wx.navigateTo({
      url: '../vehicle/vehicle' ,
    })
  },
  // 车辆信息跳转
  image:function () {
    this.data.imagepl1=1;
    wx.navigateTo({
      url: '../image/image' ,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {


      this.setData({
        'app.globalData.synbasic':app.globalData.synbasic
      })

      this.setData({
        'app.globalData.synwork':app.globalData.synwork
      })

      this.setData({

        'app.globalData.syncontract':app.globalData.syncontract
      })
      this.setData({

        'app.globalData.syncar':app.globalData.syncar
      })
      this.setData({

        'app.globalData.synphoto':app.globalData.synphoto
      })

      if(options.syn){

        if(options.syn == 'basic'){

          
          app.globalData.synbasic = '已完善';
          this.setData({

            'app.globalData.synbasic':'已完善'

          })

        }

        if(options.syn == 'work')
        {

          app.globalData.synwork = '已完善';
         
          this.setData({

            'app.globalData.synwork':'已完善'

          })
        }

        if(options.syn == 'contract')
        {

          app.globalData.syncontract = '已完善';
         
          this.setData({

            'app.globalData.syncontract':'已完善'

          })
        }
        
        if(options.syn == 'car')
        {

          app.globalData.syncar = '已完善';
         
          this.setData({

            'app.globalData.syncar':'已完善'

          })
        }

        if(options.syn == 'photo')
        {

          app.globalData.synphoto = '已完善';
         
          this.setData({

            'app.globalData.synphoto':'已完善'

          })
        }

      }


        if(options.ordernum)
        {

          console.log(options.ordernum);
          wx.setStorageSync('ordernum', options.ordernum);


        }


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {



  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})